package com.loveprogrammer.dto.job;

import com.loveprogrammer.utils.ConsoleColors;
import lombok.Data;

import java.util.Optional;

/**
 * @ClassName Equip
 * @Description 装备
 * @Author admin
 * @Date 2024/2/28 9:54
 * @Version 1.0
 */
@Data
public class Equip extends GoodsInfo{
    private int strength;                  // 力量 影响物理输出 物理技能输出
    private int armature;                 // 护甲值 影响物理防御和法术防御
    private int constitution;               // 体质 影响生命值 一点体质增加10点生命值
    private int magic;                       // 魔力 影响法术输出 法术技能输出
    private int technique;                   // 技巧 影响闪避率、暴击率
    private int speed;                         // 攻击速度
    private int difference;
    private String position;                    // 位置

    // 物品打印信息的重写
    @Override
    public String toString() {
        return "*物品信息* " +
                "名称：" + getName() + " " + "级别：" + getLevel() + " " +
                "品质：" + this.quality + " " +
                (strength > 0 ? ("力量：" + strength + " ") : "") +
                (armature > 0 ? ("护甲：" + armature + " ") : "") +
                (constitution > 0 ? ("体力：" + constitution + " ") : "") +
                (magic > 0 ? ("魔力：" + magic + " ") : "") +
                (technique > 0 ? ("技巧：" + technique + " ") : "") +
                (speed > 0 ? ("速度：" + speed + " ") : "") +
                (getPoisonResistance() > 0 ? ("毒抗：" + getPoisonResistance() + " ") : "") +
                (getFlameResistance() > 0 ? ("火抗：" + getFlameResistance() + " ") : "") +
                (getThunderResistance() > 0 ? ("雷抗：" + getThunderResistance() + " ") : "") +
                (getIceResistance() > 0 ? ("冰抗：" + getIceResistance() + " ") : "") +
                "；";
    }

    // 物品打印信息的重写
    public String prettyPrint() {
        return string + "****物品信息****\n" +
                string + "名称：" + getName() + "\n" +
                string + "品质：" + this.quality + "\n" +
                string + "位置：" + Optional.ofNullable(this.getPosition()).orElse("装备") + "\n" +
                string + "说明：" + getDesc() + "\n" +
                (strength > 0 ? (string + "力量：" + strength + "\n") : "") +
                (armature > 0 ? (string + "护甲：" + armature + "\n") : "") +
                (constitution > 0 ? (string + "体力：" + constitution + "\n") : "") +
                (magic > 0 ? (string + "魔力：" + magic + "\n") : "") +
                (technique > 0 ? (string + "技巧：" + technique + "\n") : "") +
                (speed > 0 ? (string + "速度：" + speed + "\n") : "") +
                (getPoisonResistance() > 0 ? (string + "毒抗：" + getPoisonResistance() + "\n") : "") +
                (getFlameResistance() > 0 ? (string + "火抗：" + getFlameResistance() + "\n") : "") +
                (getThunderResistance() > 0 ? (string + "雷抗：" + getThunderResistance() + "\n") : "") +
                (getIceResistance() > 0 ? (string + "冰抗：" + getIceResistance() + "\n") : "") +
                string + "" + "***************";
    }
}
